package cc.mrbird.statistical.controller;

import cc.mrbird.assets.domain.AssetType;
import cc.mrbird.common.annotation.Log;
import cc.mrbird.common.controller.BaseController;
import cc.mrbird.common.domain.ResponseBo;
import cc.mrbird.common.util.TimeUtil;
import cc.mrbird.plan.domain.Inspection;
import cc.mrbird.statistical.service.EquipmentAnalysisService;
import cc.mrbird.statistical.service.impl.EquipmentAnalysisServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(description = "设备分析管理接口")
@Controller
public class EquipmentAnalysisController extends BaseController {
    /*private Logger log = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private EquipmentAnalysisService equipmentAnalysisService;
   *//* 1. 消防责任单位的各类消防设备的故障率统计和误报率统计(先不考虑)。该部分可以考虑在主窗口划分多个区域，
    可以同时显示每类消防设备的统计数据。*//*
   @ApiOperation(value = "设备的故障率统计信息")
   @Log("设备的故障率统计信息")
   @RequestMapping(value = "equipmentAnalysis/findfailureRate" ,method = RequestMethod.GET)
   @ResponseBody
   public ResponseBo failureRateStatistics(String nextTime) {//故障率统计  nextTime指定分析的时间区间
       Map<String,Float> failureRateStatisticsMap  =  new HashMap<>();
       try {
           if(StringUtils.isEmpty(nextTime)){
               nextTime = TimeUtil.ComputationTime("1年");
           }else {
               nextTime = TimeUtil.ComputationTime(nextTime);
           }
           failureRateStatisticsMap = this.equipmentAnalysisService.failureRateStatistics(nextTime);
           return ResponseBo.ok(failureRateStatisticsMap);
       } catch (Exception e) {
           log.error("设备的故障率统计失败", e);
           return ResponseBo.error("查询设备的故障率统计失败，请联系网站管理员！");
       }
   }

   // 可以显示故障率和误报率(暂时不考虑)数据中最好TOP10和最坏TOP10设备(数量可以设置)
   @ApiOperation(value = "设备的故障率统计信息")
   @Log("设备的故障率统计信息")
   @RequestMapping(value = "equipmentAnalysis/findfailureRate" ,method = RequestMethod.GET)
   @ResponseBody
   public ResponseBo failureRateRankings(Integer number) { //设置显示数量
       try {
           if(number == null){
               number = 10;
           }

           return ResponseBo.ok();
       } catch (Exception e) {
           log.error("设备的故障率统计失败", e);
           return ResponseBo.error("查询设备的故障率统计失败，请联系网站管理员！");
       }
   }*/

}
